//Contact Form
$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("input#name").focus();
      return false;
    }
    
	  var adrs = $("input#adrs").val();
		if (adrs == "") {
      $("input#adrs").focus();
      return false;
    }
    
		var email = $("input#email").val();
		if (email == "") {
      $("input#email").focus();
      return false;
    }
    
		var phone = $("input#phone").val();
		if (phone == "") {
      $("input#phone").focus();
      return false;
    }	
	
		var project = $("textarea#project").val();
		if (project == "") {
      $("input#project").focus();
      return false;
    }
		
	var dataString = 'name='+ name + '&email=' + email  + '&adrs=' + adrs + '&phone=' + phone + '&project=' + project;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "contact.php",
      data: dataString,
      success: function() {
        $('#contact > section').html("<section id='message'></section>");
        $('#message').html("<h2>You're fantastic, honestly!<br/>I'll be in contact with you shortly.</h2>")
        .hide()
        .fadeIn(1500, function() {
         
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});

